// pages/dhl/index.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        list: [],
        listt: [],
        listtt: [],
        listttt: [],
        listtttt: [],
        llist: [],
        lllist: [],
        listxu: [],
        safs: [],
        xh: 1,
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.getlist();
        this.getlistt();
        this.getlisttt();
        this.getlistttt();
        this.getlisttttt();
        this.getllist();
        this.getlllist();
        this.getlistxu();
        this.getsafs();
    },
    getlist() {
        let that = this;
        // console.log(1)
        wx.request({
            url: 'https://console-mock.apipost.cn/app/mock/project/735a2577-da8b-467d-b76c-09349f9d8f3c/banner',
            method: "GET",
            success(res) {
                console.log(res)
                that.setData({
                    list: res.data.data
                })
            }

        })
    },
    getlistt() {
        let that = this
        wx.request({
            url: 'https://console-mock.apipost.cn/app/mock/project/735a2577-da8b-467d-b76c-09349f9d8f3c/adver',
            method: "GET",
            success(res) {
                console.log(res)
                that.setData({
                    listt: res.data
                })
            }
        })
    },
    getlisttt() {
        let that = this
        wx.request({
            url: 'https://console-mock.apipost.cn/app/mock/project/735a2577-da8b-467d-b76c-09349f9d8f3c/cates',
            method: "GET",
            success(res) {
                console.log(res)
                that.setData({
                    listtt: res.data.data
                })
            }
        })
    },
    getlistttt() {
        let that = this
        wx.request({
            url: 'https://console-mock.apipost.cn/app/mock/project/735a2577-da8b-467d-b76c-09349f9d8f3c/pushcate',
            method: "GET",
            success(res) {
                console.log(res)
                that.setData({
                    listttt: res.data.data
                })
            }
        })
    },
    getllist() {
        let that = this
        wx.request({
            url: 'https://console-mock.apipost.cn/app/mock/project/735a2577-da8b-467d-b76c-09349f9d8f3c/xll',
            method: "GET",
            success(res) {
                console.log(res)
                that.data.llist.push(res.data.data[0])
                that.setData({
                    llist: that.data.llist
                })
            }
        })
    },
    getlllist() {
        let that = this
        wx.request({
            url: 'https://console-mock.apipost.cn/app/mock/project/735a2577-da8b-467d-b76c-09349f9d8f3c/xll',
            method: "GET",
            success(res) {
                console.log(res)
                that.data.lllist.push(res.data.data[1])
                that.setData({
                    lllist: that.data.lllist
                })
            }
        })
    },
    getlisttttt() {
        let that = this
        wx.request({
            url: 'https://console-mock.apipost.cn/app/mock/project/735a2577-da8b-467d-b76c-09349f9d8f3c/xll',
            method: "GET",
            success(res) {
                console.log(res)
                that.data.listtttt.push(res.data.data[2])
                that.data.listtttt.push(res.data.data[3])
                that.setData({
                    listtttt: that.data.listtttt
                    // listtttt:res.data.data
                })
            }
        })
    },
    getlistxu() {
        let that = this
        wx.request({
            url: 'https://console-mock.apipost.cn/app/mock/project/735a2577-da8b-467d-b76c-09349f9d8f3c/xu',
            method: "GET",
            success(res) {
                console.log(res)
                that.setData({
                    listxu: res.data.data
                })
            }
        })
    },
    getsafs() {
        let that = this
        wx.request({
            url: 'https://console-mock.apipost.cn/app/mock/project/735a2577-da8b-467d-b76c-09349f9d8f3c/goods/' + that.data.xh,
            method: "GET",
            success(res) {
                console.log(res)
                if (0 <= res.data.data.length) {
                    for (let i = 0; i < res.data.data.length; i++) {
                        that.data.safs.push(res.data.data[i])
                    }
                    that.setData({
                        safs: that.data.safs
                    })

                } else {
                    that.setData({
                        xh: that.data.xh - 1
                    })
                }
                // that.setData({
                //     safs: res.data.data
                // })
            }
        })
    },
    Shopping:function (res) {
        console.log(res)
        wx.navigateTo({
          url: '../gouwuche/index?id=' + res.currentTarget.dataset.cs
        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
        this.setData({
            xh: this.data.xh+1
        })
        this.getsafs()
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})